﻿#if UNITY_EDITOR
using System;
/// <summary>
/// 收集参数
/// </summary>
public class AbsESF_CollectAssetArgument<T> : AbsESF_EditorAsset<AbsESF_CollectAssetArgument<T>>
    where T: AbsESF_EditorCollectAsset
{
    /// <summary>
    /// 搜索目录
    /// </summary>
    public string[] searchInFolders { get; private set; }
    /// <summary>
    /// 过滤值
    /// </summary>
    public string filter { get; private set; }
    /// <summary>
    /// 依赖项分类
    /// </summary>
    public enESF_DependencyClassify dependencyClassify = enESF_DependencyClassify.UnClude;
    /// <summary>
    /// 资源分类
    /// </summary>
    public enESF_AssetClassify assetClassify = enESF_AssetClassify.All;
    /// <summary>
    /// 显示进度条分类
    /// </summary>
    public enESF_DisplayProgressBarClassify displayProgressBarClassify = enESF_DisplayProgressBarClassify.None;
    /// <summary>
    /// 是否合法
    /// </summary>
    public Func<T, bool> funcIsLegal { get; private set; }
    /// <summary>
    /// 是否强制排除
    /// </summary>
    public Func<T,bool> funcIsForceExclude { get; private set; }
    /// <summary>
    /// 显示进度条
    /// T:节点 int:当前进度 int:总进度
    /// </summary>
    public Action<T, int, int> actionDisplayProgressBar { get; private set; }
    /// <summary>
    /// 显示可取消进度条
    /// T:节点 int:当前进度 int:总进度 bool:是否取消
    /// </summary>
    public Func<T, int, int, bool> funcDisplayCancelableProgressBar { get; private set; }

    /// <summary>
    /// 构造函数
    /// </summary>
    public AbsESF_CollectAssetArgument()
    {
        OnDispose();
    }

    #region SetFilter 设置过滤值    
    /// <summary>
    /// 设置过滤值
    /// </summary>
    /// <param name="_filter">过滤值</param>
    public void SetFilter(string _filter)
    {        
        filter = _filter;
    }
    #endregion

    #region SetSearchInFolders 设置搜索目录
    /// <summary>
    /// 设置搜索目录
    /// </summary>
    /// <param name="_searchInFolders">搜索目录</param>
    public void SetSearchInFolders(params string[] _searchInFolders)
    {
        searchInFolders = _searchInFolders;
    }
    #endregion

    #region SetIsLegal 设置是否合法回调
    /// <summary>
    /// 设置是否合法回调
    /// </summary>
    /// <param name="_IsLegal">是否合法回调</param>
    public void SetIsLegal(Func<T, bool> _IsLegal)
    {
        funcIsLegal = _IsLegal;
    }
    #endregion

    #region SetIsForceExclude 设置是否强制排除回调
    /// <summary>
    /// 设置是否强制排除回调
    /// </summary>
    /// <param name="_IsForceExclude">是否强制排除回调</param>
    public void SetIsForceExclude(Func<T, bool> _IsForceExclude)
    {
        funcIsForceExclude = _IsForceExclude;
    }
    #endregion

    #region SetDisplayProgressBar 设置显示进度条回调
    /// <summary>
    /// 设置显示进度条回调
    /// </summary>
    /// <param name="_displayProgressBar">显示进度条回调【T:节点 int:当前进度 int:总进度】</param>
    public void SetDisplayProgressBar(Action<T, int, int> _displayProgressBar)
    {
        actionDisplayProgressBar = _displayProgressBar;
    }
    #endregion

    #region SetDisplayCancelableProgressBar 设置可取消进度条回调
    /// <summary>
    /// 设置可取消进度条回调
    /// </summary>
    /// <param name="_displayCancelableProgressBar">可取消进度条回调【T:节点 int:当前进度 int:总进度 bool:是否取消】</param>
    public void SetDisplayCancelableProgressBar(Func<T, int, int, bool> _displayCancelableProgressBar)
    {
        funcDisplayCancelableProgressBar = _displayCancelableProgressBar;
    }
    #endregion

    #region OnDispose
    /// <summary>
    /// OnDispose
    /// </summary>
    protected override void OnDispose()
    {
        searchInFolders = new string[0];
        filter = string.Empty;
        dependencyClassify = enESF_DependencyClassify.UnClude;
        assetClassify = enESF_AssetClassify.All;
        displayProgressBarClassify = enESF_DisplayProgressBarClassify.None;
        funcIsLegal = null;
        funcIsForceExclude = null;
        actionDisplayProgressBar = null;
        funcDisplayCancelableProgressBar = null;
    }    
    #endregion
}
#endif
